package com.zoke.support.base;

import java.util.List;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zoke.support.indicator.lib.IndicatorViewPager.IndicatorFragmentPagerAdapter;

/**
 * 处理indicator指示器
 * 
 * @author JackWu
 * @version
 * @date 2014-10-31
 * @_QQ_ 651319154
 */
public abstract class BaseIndicatorFragmentPagerAdapter extends
		IndicatorFragmentPagerAdapter {

	protected Context mContext;
	protected List<? extends Object> mDatas;
	protected LayoutInflater inflater;

	public BaseIndicatorFragmentPagerAdapter(FragmentManager fragmentManager) {
		super(fragmentManager);
	}

	public BaseIndicatorFragmentPagerAdapter(FragmentManager fragmentManager,
			Context context, List<? extends Object> mDatas) {
		super(fragmentManager);
		this.mContext = context;
		this.mDatas = mDatas;
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return mDatas.size();
	}

	@Override
	public View getViewForTab(int position, View convertView,
			ViewGroup container) {
		return getView(position, convertView, container);
	}

	/** tab的View填充 **/
	protected abstract View getView(int position, View convertView,
			ViewGroup container);

	/** 获取convertView **/
	protected View getConvertView(View convertView, int resId) {
		if (convertView == null)
			convertView = inflater.inflate(resId, null);
		return convertView;
	}

	@Override
	public Fragment getFragmentForPage(int position) {
		return getFragment(position);
	}

	/** 获取Fragment **/
	protected abstract Fragment getFragment(int position);

}
